<?php

namespace App\Http\Requests\Frontend\V10\Loan;

use App\Models\UserChangeBankCardRecord;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class ChangeCardRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'card_id' => 'required',
            'purpose' => [
                'bail',
                'required',
                Rule::in([
                  UserChangeBankCardRecord::PURPOSE_REPAY,
                   UserChangeBankCardRecord::PURPOSE_LOAN,
                    ])
            ],
        ];
    }

    public  function  messages()
    {
       return  [
           'card_id.required' => '缺少银行卡ID',
           'purpose.required' => '缺少银行卡用途',
           'purpose.in' => '银行卡用途格式不正确',
       ];
    }
}
